{-# LANGUAGE DeriveDataTypeable #-}
----------------------------------------------------------------
--                                                            --
-- Module      :  LLVM.Code.Constant                          --
-- License     :  GPL3                                        --
-- Mantainer   :  Mikhail Belyaev                             --
--                                                            --
----------------------------------------------------------------

module LLVM.Code.Values.Kinds where

import Data.Generics(Typeable, Data)

import LLVM.Code.Shared
       (GCIndex(..), SectionIndex(..), ParamAttrIndex(..), CallingConv,
        BBIndex(..), TypeIndex(..), CastOpcode, BinOpcode, LinkageType,
        VisibilityType, ValIndex(..))
import LLVM.Code.Instructions.Values (DebugLoc(..), Instruction)

data AliasValue = AliasValue ValIndex VisibilityType LinkageType deriving (Show,Eq,Typeable,Data)

data ConstantValue = Null |
                   Undefined |
                   IntegerC Integer |
                   WIntegerC [Integer] |
                   FloatC Float |
                   Aggregate [ValIndex] |
                   StringC String |
                   CStringC String |
                   BinOpC BinOpcode ValIndex ValIndex |
                   CastOpC CastOpcode TypeIndex ValIndex |
                   GepOpC | -- !!
                   SelectOpC ValIndex ValIndex ValIndex |
                   ExtractOpC TypeIndex ValIndex ValIndex |
                   InsertOpC ValIndex ValIndex ValIndex |
                   ShuffleOpC ValIndex ValIndex ValIndex |
                   CmpOpC TypeIndex ValIndex ValIndex ValIndex |
                   InlineASM | -- !!
                   ShuffleOpCEx TypeIndex ValIndex ValIndex ValIndex |
                   InBoundGEPOpC [ValIndex] |
                   BlockAddress TypeIndex ValIndex BBIndex
                   deriving (Show, Eq, Typeable, Data)

data FunctionAttrs = FunctionAttrs {
                        fcallconv :: CallingConv,
                        flinkage :: LinkageType,
                        fparamattrs :: Maybe ParamAttrIndex,
                        falignment :: Integer,
                        fsection :: Maybe SectionIndex,
                        fvisibility :: VisibilityType,
                        flocalgc :: Maybe GCIndex
                    } deriving (Show, Eq, Typeable, Data)

data FunctionDeclValue = FunctionDeclValue {
                            isAbstract :: Bool,
                            functionDeclAttrs :: FunctionAttrs
                         } deriving (Show, Eq, Typeable, Data)


data ParameterValue = ParameterValue {
                        parameterNum :: Integer
                      } deriving (Show, Eq, Typeable, Data)

data GlobalValue = GlobalValue {
                        isConst :: Bool,
                        initId :: Maybe ValIndex,
                        linkage :: LinkageType,
                        alignment :: Integer,
                        section :: Integer,
                        visibility :: VisibilityType,
                        isThreadLocal :: Bool
                   } deriving (Show, Eq, Typeable, Data)

data InstructionValue = InstructionValue Instruction (Maybe DebugLoc) deriving (Show, Eq, Typeable, Data)


data MetaValue = MetaAccessor {
                    target :: ValIndex
                 } deriving (Show, Eq, Typeable, Data)
